package com.mrjy.maintain.bo;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mrjy.common.entity.PromoteDetail;
import com.mrjy.common.entity.PromoteSettleInfo;
import com.mrjy.common.entity.UserBalancePayment;
import com.mrjy.maintain.dao.IPromoteDetailDao;
import com.mrjy.maintain.dao.IPromoteSettleInfoDao;

@Service
public class PromoteSettleInfoBo implements IPromoteSettleInfoBo {
	
	@Autowired
	private IPromoteSettleInfoDao promoteSettleInfoDao;
	@Autowired
	private IPromoteDetailDao promoteDetailDao;
	
	@Override
	public Object queryByPromoteId(PromoteSettleInfo info) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		PromoteSettleInfo promoteSettleInfo = promoteSettleInfoDao.queryByPromoteId(info);
		if (promoteSettleInfo!=null) {
			promoteSettleInfo.setSettleTimeString(sdf.format(promoteSettleInfo.getSettleTime()));
		}
		return promoteSettleInfo;
	}

	@Override
	public void insertBatch(List<PromoteSettleInfo> list) {
		promoteSettleInfoDao.insertBatch(list);
	}

	@Override
	public Object queryByPaymentId(UserBalancePayment userBalancePayment) {
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		PromoteSettleInfo info = (PromoteSettleInfo) promoteSettleInfoDao.queryByPaymentId(userBalancePayment);
		if (info!=null) {
			info.setSettleTimeString(sdf.format(info.getSettleTime()));
		}
		return info;
				
	}

}
